<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script>
			window.onload = function(){
				var oSp = document.getElementById("sp1");
//				获得父亲节点
				var p = oSp.parentNode;
				console.log(p);
				
				var oDiv1 = document.getElementById("div1");
//				var childs = oDiv1.childNodes;
//
//				var eleChilds = getElementChild(childs);
//				console.log(eleChilds)
				
				//获得元素儿子   children
				var childElements = oDiv1.children;
				console.log(childElements);
				
//				var xiongdi = oDiv1.nextSibling;
//				nextElementSibling获得下一个兄弟元素节点
				var xdElment = oDiv1.nextElementSibling;
				console.log(xdElment);
//				previousElementSibling
				var dgElement = oDiv1.previousElementSibling;
				console.log(dgElement);
			}
			
			
			function getElementChild(arr){
				var newArr = [];
				for(var i=0;i<arr.length;i++){
					if(arr[i].nodeType==1){
						newArr.push(arr[i]);
					}
				}
				return newArr;
			}
		</script>
		<div id="div0"></div>
		<div id="div1">
			<div class="c1">
				<span id="sp1">我是span</span>
			</div>
			<p>我是p标签</p>
		</div>
		<div id="div2">
			我是div2
		</div>
	</body>
</html>
